import axios from 'axios'
import timeout from './error'
import url from './config'

const errMsg = 'tomcat原地爆炸'
export default {
  login (params) {
    return new Promise((resolve, reject) => {
      axios.post(`${url}/user/login`, {...params})
        .then(data => {
          if (data.data.data.success === true) {
            resolve(data.data)
          } else {
            reject(data.data.data.message)
          }
        })
        .catch(() => {
          reject(errMsg)
        })
      timeout(reject)
    })
  }
}
